

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>quippy.polarization &mdash; quippy 7ea04c5+ documentation</title>
  

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../_static/doctools.js"></script>
        <script type="text/javascript" src="../../_static/language_data.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "math|output_area", "processEscapes": true, "ignoreClass": "document", "inlineMath": [["$", "$"], ["\\(", "\\)"]]}})</script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/theme_overrides.css" type="text/css" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> quippy
          

          
            
            <img src="../../_static/hybrid.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                7ea04c5+
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
    
            
            
              
            
            
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to <code class="docutils literal notranslate"><span class="pre">quippy</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install.html">Installation of QUIP and quippy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../Tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quippy.html">Quippy library reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../visualisation.html">Visualisation Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../fortran_wrapper.html">Appendix: wrapping Fortran 90 Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../teach_sparse.html">Command line options of the teach_sparse main program</a></li>
</ul>

            
          
    <p></p>
    <ul>
        <li><a href="../../genindex.html">Index</a></li>
        <li><a href="../../py-modindex.html">Module Index</a></li>
        <li><a href="../../search.html">Search Page</a></li>
        <li><a href="../index.html">Module Source Code</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">quippy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>quippy.polarization</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for quippy.polarization</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;This module contains utility functions for polarizable potentials.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">quippy.units</span> <span class="k">import</span> <span class="n">BOHR</span><span class="p">,</span> <span class="n">HARTREE</span><span class="p">,</span> <span class="n">PI</span>
<span class="kn">from</span> <span class="nn">quippy.farray</span> <span class="k">import</span> <span class="n">fzeros</span><span class="p">,</span> <span class="n">frange</span><span class="p">,</span> <span class="n">fidentity</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;born_effective_charge&#39;</span><span class="p">,</span> <span class="s1">&#39;epsilon_infty&#39;</span><span class="p">,</span> <span class="s1">&#39;screened_effective_charge&#39;</span><span class="p">]</span>

<div class="viewcode-block" id="born_effective_charge"><a class="viewcode-back" href="../../polarization.html#quippy.polarization.born_effective_charge">[docs]</a><span class="k">def</span> <span class="nf">born_effective_charge</span><span class="p">(</span><span class="n">pot</span><span class="p">,</span> <span class="n">at0</span><span class="p">,</span> <span class="n">dx</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">,</span> <span class="n">args_str</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
   <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">   Calculate Born effective charges for all atoms in at0</span>

<span class="sd">   Potential must be polarizable, i.e. compute dipole moments.</span>
<span class="sd">   &quot;&quot;&quot;</span>

   <span class="n">born_tensor</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="n">at0</span><span class="o">.</span><span class="n">n</span><span class="p">))</span>

   <span class="n">restart</span> <span class="o">=</span> <span class="kc">True</span>
   <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="n">at0</span><span class="o">.</span><span class="n">n</span><span class="p">):</span>
      <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>

         <span class="n">at</span> <span class="o">=</span> <span class="n">at0</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
         <span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[</span><span class="n">j</span><span class="p">,</span><span class="n">i</span><span class="p">]</span> <span class="o">-=</span> <span class="n">dx</span>
         <span class="n">at</span><span class="o">.</span><span class="n">calc_connect</span><span class="p">()</span>

         <span class="n">pot</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">restart</span><span class="o">=</span><span class="n">restart</span><span class="p">,</span> <span class="n">args_str</span><span class="o">=</span><span class="n">args_str</span><span class="p">)</span>
         <span class="n">restart</span> <span class="o">=</span> <span class="kc">True</span>

         <span class="n">dip1</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
         <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="n">at</span><span class="o">.</span><span class="n">n</span><span class="p">):</span>
            <span class="n">dip1</span> <span class="o">+=</span> <span class="n">at</span><span class="o">.</span><span class="n">dipoles</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="n">at</span><span class="o">.</span><span class="n">charge</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">*</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[:,</span><span class="n">k</span><span class="p">]</span>

         <span class="n">at</span> <span class="o">=</span> <span class="n">at0</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
         <span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[</span><span class="n">j</span><span class="p">,</span><span class="n">i</span><span class="p">]</span> <span class="o">+=</span> <span class="n">dx</span>
         <span class="n">at</span><span class="o">.</span><span class="n">calc_connect</span><span class="p">()</span>

         <span class="n">pot</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">restart</span><span class="o">=</span><span class="n">restart</span><span class="p">,</span> <span class="n">args_str</span><span class="o">=</span><span class="n">args_str</span><span class="p">)</span>
         
         <span class="n">dip2</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
         <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="n">at</span><span class="o">.</span><span class="n">n</span><span class="p">):</span>
            <span class="n">dip2</span> <span class="o">+=</span> <span class="n">at</span><span class="o">.</span><span class="n">dipoles</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span> <span class="n">at</span><span class="o">.</span><span class="n">charge</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">*</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[:,</span><span class="n">k</span><span class="p">]</span>

         <span class="n">born_tensor</span><span class="p">[:,</span><span class="n">j</span><span class="p">,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">dip2</span> <span class="o">-</span> <span class="n">dip1</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">dx</span><span class="o">*</span><span class="mf">2.0</span><span class="p">)</span>

   <span class="k">return</span> <span class="n">born_tensor</span></div>
         

<div class="viewcode-block" id="epsilon_infty"><a class="viewcode-back" href="../../polarization.html#quippy.polarization.epsilon_infty">[docs]</a><span class="k">def</span> <span class="nf">epsilon_infty</span><span class="p">(</span><span class="n">pot</span><span class="p">,</span> <span class="n">at</span><span class="p">,</span> <span class="n">deltafield</span><span class="o">=</span><span class="mf">0.001</span><span class="p">,</span> <span class="n">zerotol</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">):</span>
   <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">   Calculate dielectric tensor.</span>

<span class="sd">   Potential must be polarisable and allow an external electic field to be applied.</span>
<span class="sd">   &quot;&quot;&quot;</span>

   <span class="n">dielectric_tensor</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span>
   <span class="n">celldip</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span>

   <span class="c1"># Calculation with no applied field</span>
   <span class="n">pot</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">restart</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">applied_efield</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
   <span class="n">celldip0</span> <span class="o">=</span> <span class="n">at</span><span class="o">.</span><span class="n">dipoles</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="n">BOHR</span>

   <span class="n">at</span><span class="o">.</span><span class="n">add_property</span><span class="p">(</span><span class="s1">&#39;ext_efield&#39;</span><span class="p">,</span> <span class="mf">0.</span><span class="p">,</span> <span class="n">n_cols</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>

   <span class="c1"># Now we apply field along each of x,y,z in turn, and</span>
   <span class="c1"># calculate overall cell dipole moment</span>
   <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>

      <span class="n">at</span><span class="o">.</span><span class="n">ext_efield</span><span class="p">[:]</span> <span class="o">=</span> <span class="mf">0.0</span>
      <span class="n">at</span><span class="o">.</span><span class="n">ext_efield</span><span class="p">[</span><span class="n">i</span><span class="p">,:]</span> <span class="o">+=</span> <span class="n">deltafield</span><span class="o">/</span><span class="p">(</span><span class="n">BOHR</span><span class="o">/</span><span class="n">HARTREE</span><span class="p">)</span>

      <span class="n">pot</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">applied_efield</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
      <span class="n">celldip</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">at</span><span class="o">.</span><span class="n">dipoles</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="n">BOHR</span>
      <span class="n">dielectric_tensor</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">celldip</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">celldip0</span>
      
   <span class="n">dielectric_tensor</span> <span class="o">=</span> <span class="mf">4.0</span><span class="o">*</span><span class="n">PI</span><span class="o">*</span><span class="n">dielectric_tensor</span><span class="o">/</span><span class="n">deltafield</span><span class="o">/</span><span class="p">(</span><span class="n">at</span><span class="o">.</span><span class="n">cell_volume</span><span class="p">()</span><span class="o">/</span><span class="n">BOHR</span><span class="o">**</span><span class="mi">3</span><span class="p">)</span> <span class="o">+</span> <span class="n">fidentity</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
   <span class="n">at</span><span class="o">.</span><span class="n">ext_efield</span><span class="p">[:]</span> <span class="o">=</span> <span class="mf">0.0</span>

   <span class="n">dielectric_tensor</span><span class="p">[</span><span class="n">dielectric_tensor</span> <span class="o">&lt;</span> <span class="n">zerotol</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>

   <span class="k">return</span> <span class="n">dielectric_tensor</span></div>
      

<span class="k">def</span> <span class="nf">calc_effective_charge_vectors</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">born_tensor</span><span class="p">):</span>

   <span class="n">effective_charge</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
   <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">n</span><span class="p">):</span>
      <span class="n">p_norm</span> <span class="o">=</span> <span class="n">a</span><span class="o">.</span><span class="n">phonon</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">/</span><span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">phonon</span><span class="p">[</span><span class="n">i</span><span class="p">],</span><span class="n">a</span><span class="o">.</span><span class="n">phonon</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
      <span class="n">disp</span> <span class="o">=</span> <span class="p">(</span><span class="n">p_norm</span><span class="o">/</span><span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">ElementMass</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">species</span><span class="p">[</span><span class="n">i</span><span class="p">])]</span><span class="o">*</span><span class="n">MASSCONVERT</span><span class="p">))</span><span class="o">/</span><span class="n">BOHR</span>
      <span class="nb">print</span> <span class="n">disp</span>
      <span class="n">effective_charge</span> <span class="o">=</span> <span class="n">effective_charge</span> <span class="o">+</span> <span class="n">dot</span><span class="p">(</span><span class="n">born_tensor</span><span class="p">[:,:,</span><span class="n">i</span><span class="p">],</span> <span class="n">disp</span><span class="p">)</span>

   <span class="k">return</span> <span class="n">effective_charge</span>

<div class="viewcode-block" id="screened_effective_charge"><a class="viewcode-back" href="../../polarization.html#quippy.polarization.screened_effective_charge">[docs]</a><span class="k">def</span> <span class="nf">screened_effective_charge</span><span class="p">(</span><span class="n">born</span><span class="p">,</span> <span class="n">eps</span><span class="p">):</span>
   <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">   Compute screened effective charge tensor from Born and dielectric tensors</span>
<span class="sd">   &quot;&quot;&quot;</span>

   <span class="n">screened</span> <span class="o">=</span> <span class="n">fzeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span>
   <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
      <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
         <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
               <span class="k">if</span> <span class="n">eps</span><span class="p">[</span><span class="n">k</span><span class="p">,</span><span class="n">l</span><span class="p">]</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">:</span> <span class="k">continue</span>
               <span class="n">screened</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">,</span><span class="n">l</span><span class="p">]</span> <span class="o">=</span> <span class="n">born</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">]</span><span class="o">/</span><span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">eps</span><span class="p">[</span><span class="n">k</span><span class="p">,</span><span class="n">l</span><span class="p">])</span>

   <span class="k">return</span> <span class="n">screened</span></div>

<span class="k">def</span> <span class="nf">dipole_moment</span><span class="p">(</span><span class="n">at</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">at</span><span class="o">.</span><span class="n">charge</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">silica_dipole_moment</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">mask</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">q_si</span><span class="o">=</span><span class="mf">1.0</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">mask</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">mask</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">at</span><span class="o">.</span><span class="n">indices</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">q_si</span><span class="o">*</span><span class="p">(</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[:,(</span><span class="n">at</span><span class="o">.</span><span class="n">z</span> <span class="o">==</span> <span class="mi">14</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">mask</span><span class="p">]</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="o">-</span>
                 <span class="mf">0.5</span><span class="o">*</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[:,(</span><span class="n">at</span><span class="o">.</span><span class="n">z</span> <span class="o">==</span> <span class="mi">8</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">mask</span><span class="p">]</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="o">+</span>
                 <span class="mf">0.25</span><span class="o">*</span><span class="n">at</span><span class="o">.</span><span class="n">pos</span><span class="p">[:,(</span><span class="n">at</span><span class="o">.</span><span class="n">z</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">mask</span><span class="p">]</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">))</span>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2008-2016, James Kermode

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>